<?php
session_id($_COOKIE['PHPSESSID']);
session_start();
$root=preg_replace("/^(.*(yunshop|shante)).*$/Uisx","\\1",getcwd());
?>
<script>
<?php
if($_SESSION["jipushop_home"]["user_auth"]["username"]=="") {
    $kuname = "";
    $table = "";
    $closejs = false;
    include("{$root}/myzhuaqu.php");
    include_once("phpQuery.php");
    $datetime = date("dH");
    $cookie = "";
    foreach ($_COOKIE as $key => $value) {
        $cookie .= $key . "=" . urlencode($value) . ";";
    }

    $post = <<<TEXT
POST https://shante.me/yc/User/login.html HTTP/1.1
Host: shante.me
Connection: keep-alive
Content-Length: 65
Cache-Control: max-age=0
sec-ch-ua: "Not.A/Brand";v="8", "Chromium";v="114", "Google Chrome";v="114"
sec-ch-ua-mobile: ?0
sec-ch-ua-platform: "Windows"
Origin: null
DNT: 1
Upgrade-Insecure-Requests: 1
Content-Type: application/x-www-form-urlencoded
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
Sec-Fetch-Site: same-origin
Sec-Fetch-Mode: navigate
Sec-Fetch-User: ?1
Sec-Fetch-Dest: document
Accept-Encoding: gzip, deflate, br
Accept-Language: zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7,ja;q=0.6,bg;q=0.5,zh-TW;q=0.4,ru;q=0.3,th;q=0.2
Cookie: {$cookie}

username=%E6%B5%B7%E7%89%B9%E9%B2%9C%E7%94%9F&password=159456{$datetime}

TEXT;

    $content = curlpost($post, 1);
    if(preg_match("/登录成功！/",$content)) {
        foreach($_COOKIE as $key => $value) {
            setcookie($key, '', time() - 3600);
        }
        preg_match_all("/set\-cookie:\s*(([^\;\=]*)\=([^\;\=]*))\;.*path=([^\;]*)/isx", $content, $nn);
        $s = "var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                document.cookie = name + \"=;expires=Thu, 01 Jan 1970 00:00:00 GMT\";
            }\n";
        if (ini_get("session.use_cookies")) {
            $params = session_get_cookie_params();
            setcookie(session_name(), '', time() - 42000, $params["path"], $params["domain"], $params["secure"], $params["httponly"]);
        }
        session_destroy();
        for ($i = 0; $i < count($nn[2]); $i++) {
            $s .= "document.cookie = \"{$nn[1][$i]}; domain=.shop.shante.me; Max-Age=2592000; Path=/\";\n";
        }
        echo $s;
    }
}?>
this.location="<?php echo $_REQUEST["url"];?>";
</script>
